# All files in the 'lib' directory will be loaded
# before nanoc starts compiling.

ENGINE_VERSION = "0.0.0-5"  # The global website engine version

require 'yaml'

# nanoc built-in helpers
include Nanoc::Helpers::Rendering   # To use partial rendering
include Nanoc::Helpers::XMLSitemap  # XML sitemap generation

# Our custom helpers
#
## These helpers should only return models, list etc...
include NewsHelper
include StatsHelper
include PersonHelper
include TagHelper
include SlugHelper

@images_per_persons = Hash.new

# Here is the global access to site config file
def siteconfig(name)
  raise "siteconfig() key can't be nil" if name.nil?
  raise "Please create a siteconfig.yml file" unless 
    File.exists? 'siteconfig.yml'

  return ENGINE_VERSION if name.to_s == 'version' # :version special case

  cfg = YAML.load_file('siteconfig.yml')
  val = cfg[name.to_s]
  raise "siteconfig is returning a nil value for #{name} key" if val.nil?

  val
end
